﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Tong;
public partial class aspnet_admin_bock_keyWord_CX_keyWord_Edit : System.Web.UI.Page
{
    /// <summary>
    /// 数据操作通用类 实例 TextData
    /// </summary> 
    public TongUse TextData = new TongUse();


    /// <summary>
    /// 用户存放数据的临时表
    /// </summary>
    DataTable MyDt = new DataTable();


    /// <summary>
    /// id
    /// </summary>
    string id = "";
    /// <summary>
    /// 爱问的实列
    /// </summary>
    Tong.IAsk.IaskDataOrstr Ask = new Tong.IAsk.IaskDataOrstr();

    protected void Page_Load(object sender, EventArgs e)
    {

        if (IsPostBack)
        {
            try
            {
                id = Request.QueryString["id"].Trim();

                PageSave(int.Parse(id));
            }
            catch
            {
                Response.Write("");
            }
        }

            PageLand_First();


     
    }

    /// <summary>
    /// 加载时出现的东东
    /// </summary>
    protected void PageLand_First()
    {
        try
        {
            id = Request.QueryString["id"].Trim();
            int.Parse(id);

            //更新用户级别 
            Ask.Iask传入用户ID更新用户级别(id.ToString());

            MyDt = TextData.SqlataSet("select * from [Ask_user] where askuser_id  =" + id + "").Tables[0];

            askuser_Name.Text = MyDt.Rows[0]["askuser_Name"].ToString().Trim();
            askuser_Name_li.Text = MyDt.Rows[0]["askuser_Name_li"].ToString().Trim();
            askuser_sex.Value = MyDt.Rows[0]["askuser_sex"].ToString().Trim();

            askuser_LX.Value = MyDt.Rows[0]["askuser_LX"].ToString().Trim();//用户类型
            askuser_feng.Text = MyDt.Rows[0]["askuser_feng"].ToString().Trim();
            askuser_QQ.Text = MyDt.Rows[0]["askuser_QQ"].ToString().Trim();
            askuser_query.Text = MyDt.Rows[0]["askuser_query"].ToString().Trim();
            askuser_answer .Text =  MyDt.Rows[0]["askuser_answer"].ToString().Trim();
            askuser_Sort.Text = MyDt.Rows[0]["askuser_Sort"].ToString().Trim();
            askuser_LV.Text = Ask.IaskGetLvTable(MyDt.Rows[0]["askuser_LV"].ToString().Trim()).Rows[0][1].ToString();//会员等级
            askuser_Email.Text = MyDt.Rows[0]["askuser_Email"].ToString().Trim();
        }
        catch
        {
            tt.Text = "不存在的用户";
            
        }
    }


    protected void PageSave(int id)
    {

        try
        {
            int.Parse(askuser_Sort.Text.Trim());
            if (askuser_Name_li.Text != "" && askuser_Name_li.Text.Length < 50)
            {
                if (int.Parse(askuser_Sort.Text.Trim()) <= 99999)
                {
                    TextData.SqlDataSave("update [Ask_user] Set  askuser_Name_li='" + askuser_Name_li.Text.Trim() + "',askuser_Sort = " + askuser_Sort.Text.Trim() + ",askuser_sex='" + askuser_sex.Value + "',askuser_answer=" + askuser_answer.Text.Trim() +
                       
                        ",askuser_feng=" +int.Parse(askuser_feng.Text.Trim())+//用户积分
                        ",askuser_LX="+int.Parse(askuser_LX.Value.Trim())+//用户类型
                      
                        "  where askuser_id=" + id);

                    tt.Text = "更新用户" + askuser_Name.Text + "成功";
                }
                else
                {
                    tt.Text = "排序超出范围";
                }
            }
            else
            {
                tt.Text = "输入的关键字为空或超过250个或不存在此关键字";

            }
        }
        catch
        {
            tt.Text = "排序超出范围";
        }

    }
    



}
